import { request } from '../http'

// 获取设备列表（分页）
export function fetchDeviceList(params: { page?: number, pageSize?: number, name?: string, address?: string, type?: string }) {
  return request.Get<Service.ResponseResult<Api.Device.PageResponse>>('/api/device/list', { params })
}

// 获取所有设备
export function fetchAllDevices() {
  return request.Get<Service.ResponseResult<Api.Device.Info[]>>('/api/devices')
}

// 获取单个设备
export function fetchDevice(name: string) {
  return request.Get<Service.ResponseResult<Api.Device.Info>>(`/api/device/${name}`)
}

// 添加设备
export function addDevice(data: Api.Device.AddRequest) {
  return request.Post<Service.ResponseResult<null>>('/api/device', data)
}

// 更新设备
export function updateDevice(data: Api.Device.UpdateRequest) {
  return request.Put<Service.ResponseResult<null>>('/api/device', data)
}

// 删除设备
export function deleteDevice(name: string) {
  return request.Delete<Service.ResponseResult<null>>(`/api/device/${name}`)
}

